package easy

import (
	"workspace/node"
)

func Postorder(root *node.Node) []int {
	var dfs func(root *node.Node)
	var res []int
	dfs = func(node *node.Node) {
		if node == nil {
			return
		}
		for _, node := range node.Children {
			dfs(node)
		}
		res = append(res, node.Val)
	}
	dfs(root)
	return res
}
